package com.cskaoyan.javase.oop1._7game._2pvz;

/**
 * 植物类
 * @since 10:59
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Plant {
    // 属性
    String name;
    double price;
    int hp;
    int damage;

    // 为了方便植物僵尸对象之间的交互,我们可以让植物持有僵尸对象的引用
    Zombie plantZ;

    // 行为
    public void attack() {
        // 攻击的时候,输出攻击对象的名字
        System.out.println(name + "正在攻击" + plantZ.name);
    }

    public void beAttacked() {
        System.out.println(name + "正在被" + plantZ.name + "攻击,还剩下" + (hp - plantZ.damage) + "点血量!");
    }

    public Plant() {
    }

    public Plant(String name, double price, int hp, int damage) {
        this.name = name;
        this.price = price;
        this.hp = hp;
        this.damage = damage;
    }
}
